project( searchplugin )

# just for sure, it seems like prior versions don't find Qt4
cmake_minimum_required( VERSION 2.6.0 )

# cmake forces us to set this on linux
if ( COMMAND cmake_policy )
  cmake_policy( SET CMP0003 NEW )
endif( COMMAND cmake_policy )

# include qt library
find_package( Qt4 REQUIRED )
include( ${QT_USE_FILE} )

# cmake doesn't seem to include these automatically (needed for WebKit)
include_directories( 
    ${QT_QTNETWORK_INCLUDE_DIR} 
    ${QT_QTWEBKIT_INCLUDE_DIR} 
    ${CMAKE_INSTALL_PREFIX}/include/socialwhale # works on windows?
)

link_directories(
    ${CMAKE_INSTALL_PREFIX}/lib/socialwhale # works on windows?
)

add_definitions( -DQT_PLUGIN )
add_definitions( -DQT_SHARED )
add_definitions( -DQT_NO_DEBUG )

# set sources and headers
set( searchplugin_SRCS
    searchbox.cpp
    searchplugin.cpp
    searchtab.cpp
    searchtop.cpp
    searchtop.h
)

# headers used by MOC should be set here 
# (e.g. if the class is child of QObject)
set( searchplugin_MOC_HDRS
    searchbox.h
    searchplugin.h
    searchtab.h
)

# let qt handle the sources
qt4_wrap_cpp( searchplugin_MOCS ${searchplugin_MOC_HDRS} )

add_library( searchplugin SHARED
    ${searchplugin_SRCS} 
    ${searchplugin_MOCS}
)

target_link_libraries( searchplugin
    ${QT_LIBRARIES} 
    ${QT_QTNETWORK_LIBRARY} # like include dirs, we need to set these
    ${QT_QTWEBKIT_LIBRARY} 
) 

IF(WIN32)
    install( FILES build/libsearchplugin.so DESTINATION ${HOME_DIRECTORY}/SocialWhale/plugins )
ELSE()
    install( FILES build/libsearchplugin.so DESTINATION ${HOME_DIRECTORY}/.socialwhale/plugins )
ENDIF()
